#!/bin/bash

ROOT_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd);
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}");
NAME="${SCRIPT_NAME%.*}"	# cut extension
NAME="${NAME#*.}"			# cut number

sudo apt -y install wimtools

for file in $ROOT_PATH/$NAME/woeusb-*.bash
do

sudo cp -f "${file}" /usr/local/bin/woeusb
chmod a+x /usr/local/bin/woeusb

sudo sh -c "echo '[Desktop Entry]
Type=Application
Name=WoeUSB
Exec=bash -c \"pkttyagent --process \\\`echo \\\$\\\$\\\` & pkexec bash -c \\\"woeusb; exec bash\\\"\"
Icon=bash
Terminal=true
' > /usr/share/applications/WoeUSB.desktop"

chmod a+x /usr/share/applications/WoeUSB.desktop

break

done

